Jump to content

Recommended Posts

Posted (edited)

[EDITED]

Question about my "favorite" subject in minecraft, rendering. I wish to use a custom shader on a generated texture that is displayed by a TESR. 

public class RenderTileInscription extends TileEntitySpecialRenderer<TileInscription>{

	@Override
	public void renderTileEntityAt(TileInscription te, double x, double y, double z, float partialTicks,
			int destroyStage) {
		final MagicCircle circle = HandlerModel.getInstance().tester;//this gets an instance of a object that holdes a holds a TextureAtlasSprite
		
		if(circle != null){
			bindTexture(TextureMap.LOCATION_BLOCKS_TEXTURE);
			
			GlStateManager.pushMatrix();
			GlStateManager.disableCull();
			GlStateManager.enableBlend();
			GlStateManager.blendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
			GlStateManager.disableAlpha();
			GlStateManager.translate(x, y+0.0001f, z);
			GlStateManager.rotate(90f, 1f, 0f, 0f);
			GlStateManager.scale(0.3625f, 0.3625f, 0.3625f);
			
			UtilRender.renderStandQuadTexture(circle.getTextureSprite());//renderQuadTexture metho
			
			GlStateManager.enableAlpha();
			GlStateManager.disableBlend();
			GlStateManager.enableCull();
			GlStateManager.popMatrix();
		}
	}
	
}
////methods from UtilRender//////
public static void renderQuadTexture(TextureAtlasSprite texture, int par1, int par2, int par3, int par4, int brightness){
		Tessellator tes = Tessellator.getInstance();
		tes.getBuffer().begin(GL11.GL_QUADS, ClientProxy.POSITION_TEX_S_COMP);
		tes.getBuffer().pos(par1, par2 + par4, 0).tex(texture.getMinU(), texture.getMaxV()).lightmap(brightness, brightness).endVertex();
		tes.getBuffer().pos(par1 + par3, par2 + par4, 0).tex(texture.getMaxU(), texture.getMaxV()).lightmap(brightness, brightness).endVertex();
		tes.getBuffer().pos(par1 + par3, par2, 0).tex(texture.getMaxU(), texture.getMinV()).lightmap(brightness, brightness).endVertex();
		tes.getBuffer().pos(par1, par2, 0).tex(texture.getMinU(), texture.getMinV()).lightmap(brightness, brightness).endVertex();
		tes.draw();
}
  
public static void renderStandQuadTexture(TextureAtlasSprite texture, int brightness){	
  	renderQuadTexture(texture, 0, 0, 16, 16, brightness);
}
public static void renderStandQuadTexture(TextureAtlasSprite texture){
	renderQuadTexture(texture, 0, 0, 16, 16, 240);
}

The above code will display the correct drawn texture (made larger than a standard block for ease of sight), now the question is how to implement custom shaders. The specific shading effect I am looking to make is where an EntityPlayer instance will activate (right click) the block, that will send the information of the specified held item and the exact position relative to the bounding box where the player clicked. This will then be used by the TESR so as to display the predefined texture (the circle.getTextureSprite() part) with a "light" source of a specific color, with source position (starting point) being at the point where the player originally right clicked the block. This color will then gradually fade (like a light) over a specific area. To summarize, I wish to use a shader to create a gradual light fate effect, with passed in vars of a color (vec3 or 4), and a position relative to the texture (vec2) (these variables being provided via uniforms to a fragment shader). This should look (of better quality) like the transition (from the attached pictures) of pic1 -> pic2. Needless to say, compatible for multiple "light" sources.

 

Now from what I understand, I don't believe I need to use a vertex shader, and only a fragment shader. More so, I really don't think I need anything overly fancy, and while in non-minecraft opengl, I would use a normal mapping, for this, I would prefer to not, as the base picture should be uniform color (more or less), and I am only looking for a simple lighting overlay, not any ultra-realism. 

 

Thus, thats more or less my question: how do I do this form of effect within minecraft, preferably in a relatively simple fashion. 

 

 

state0.png pic1

state1.pngpic2

state2.pngpic3

Edited by draganz
make easier for one to read
Posted
22 hours ago, draganz said:

Question relating toward implementation within minecraft (forge). How does one go about this: I wish to have a texture (lets say a white square) that will be rendered via a TESR; lets say it looks like this (I do hope this posts correctly):

 

(p1)                 (p2)                       (p3)

      XooooooooooXoooooooooooX

      oooooooooooooooooooooooo

(p4)XoooooooooUooooooooooooX (p5)

      oooooooooooooooooooooooo 

      XoooooooooXooooooooooooX

(p6)                (p7)                          (p8)

, with the center being "U," and different points being labeled p(n) and designated with "X." So lets begin: I wish to have say p2 render (like a light) of red from its point to (creating like a  gradually fading triangle) from p1, p3, and U. This looking like (with "R being a strong red color, and "r" being a lighter, use your imagination for the gradual fading from strong to weak):

 

(p1)                 (p2)                       (p3)

      Xo rrrrrRRRRXRRRRrrrrrrrrr oX

      oooo rrrrRRRRRRRrrrr oooooo

(p4)XoooooooooUooooooooooooX (p5)

      oooooooooooooooooooooooo 

      XoooooooooXooooooooooooX

(p6)                (p7)                          (p8)

 

With p2 having the strongest point of red, and the outer "r" points being near white, needless to say, other p(n) points remaining white as well (non coloring) ; from there, it should also be possible to do the like with other colors and also using the same implementation for the remaining points on the texture, to create similar effects. How to do this is known for me going from scratch (no from within a mod in Minecraft; and as aside note, so do I know how to change the entire textures color (at once)); my question being more on the line of how to do specific vector (color) shadings on the texture, prefereably via minecrafts implementations, should it be possible.

 

example in picture format as follows (beginning texture [state0.png] => after first point shading [state1.png] => further implementation [state2.png]):

state0.png

state1.png

state2.png

Can you explain what you are trying to do? You give examples of what you have in mind, but nothing truly explaining what it is you want to do in the TESR. Rendering something through a TESR is easy if you know what you are doing, but we are gonna need a little more info about what it is you are trying to do before we can help.

Posted
On 6/1/2017 at 9:42 PM, draganz said:

I wish to use a custom shader on a generated texture that is displayed by a TESR. 

If you want to use a GLSL shader... use a GLSL shader. There is nothing stopping you. The game uses OpenGL after all and all normal GL calls are available to you. Load your shader, compile it, link to a shader program, delete the shader, bind the program, upload your data, render and you are done. Yes, you are absolutely free to use modern OpenGL(by that I mean ~<=3.3) with buffers and stuff, MC somewhat uses them already and If I recall correctly the game even requires GL3.0+ support to launch. Yes it is going to be a pain to implement with vanilla provided Tessellator's VertexBuffer as the way it uploads data is... weird. Yes, you can allocate your own buffer, put stuff in, bind and render, just like you would do for normal gl rendering. If you want more specific details you should browse lwjgl's tutorials and wiki as MC uses lwjgl.

Note that there is no guarantee that other mods will not mess stuff up(thinking about the shadersmod for example) so you should be as cautious as possible and not forget to reset all GL states and binds after you are done.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • that happens every time I enter a new dimension.
    • This is the last line before the crash: [ebwizardry]: Synchronising spell emitters for PixelTraveler But I have no idea what this means
    • What in particular? I barely used that mod this time around, and it's never been a problem in the past.
    • Im trying to build my mod using shade since i use the luaj library however i keep getting this error Reason: Task ':reobfJar' uses this output of task ':shadowJar' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. So i try adding reobfJar.dependsOn shadowJar  Could not get unknown property 'reobfJar' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. my gradle file plugins { id 'eclipse' id 'idea' id 'maven-publish' id 'net.minecraftforge.gradle' version '[6.0,6.2)' id 'com.github.johnrengelman.shadow' version '7.1.2' id 'org.spongepowered.mixin' version '0.7.+' } apply plugin: 'net.minecraftforge.gradle' apply plugin: 'org.spongepowered.mixin' apply plugin: 'com.github.johnrengelman.shadow' version = mod_version group = mod_group_id base { archivesName = mod_id } // Mojang ships Java 17 to end users in 1.18+, so your mod should target Java 17. java.toolchain.languageVersion = JavaLanguageVersion.of(17) //jarJar.enable() println "Java: ${System.getProperty 'java.version'}, JVM: ${System.getProperty 'java.vm.version'} (${System.getProperty 'java.vendor'}), Arch: ${System.getProperty 'os.arch'}" minecraft { mappings channel: mapping_channel, version: mapping_version copyIdeResources = true runs { configureEach { workingDirectory project.file('run') property 'forge.logging.markers', 'REGISTRIES' property 'forge.logging.console.level', 'debug' arg "-mixin.config=derp.mixin.json" mods { "${mod_id}" { source sourceSets.main } } } client { // Comma-separated list of namespaces to load gametests from. Empty = all namespaces. property 'forge.enabledGameTestNamespaces', mod_id } server { property 'forge.enabledGameTestNamespaces', mod_id args '--nogui' } gameTestServer { property 'forge.enabledGameTestNamespaces', mod_id } data { workingDirectory project.file('run-data') args '--mod', mod_id, '--all', '--output', file('src/generated/resources/'), '--existing', file('src/main/resources/') } } } sourceSets.main.resources { srcDir 'src/generated/resources' } repositories { flatDir { dirs './libs' } maven { url = "https://jitpack.io" } } configurations { shade implementation.extendsFrom shade } dependencies { minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" implementation 'org.luaj:luaj-jse-3.0.2' implementation fg.deobf("com.github.Virtuoel:Pehkui:${pehkui_version}") annotationProcessor 'org.spongepowered:mixin:0.8.5:processor' minecraftLibrary 'luaj:luaj-jse:3.0.2' shade 'luaj:luaj-jse:3.0.2' } // Example for how to get properties into the manifest for reading at runtime. tasks.named('jar', Jar).configure { manifest { attributes([ 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors, 'Specification-Version' : '1', // We are version 1 of ourselves 'Implementation-Title' : project.name, 'Implementation-Version' : project.jar.archiveVersion, 'Implementation-Vendor' : mod_authors, 'Implementation-Timestamp': new Date().format("yyyy-MM-dd'T'HH:mm:ssZ"), "TweakClass" : "org.spongepowered.asm.launch.MixinTweaker", "TweakOrder" : 0, "MixinConfigs" : "derp.mixin.json" ]) } rename 'mixin.refmap.json', 'derp.mixin-refmap.json' } shadowJar { archiveClassifier = '' configurations = [project.configurations.shade] finalizedBy 'reobfShadowJar' } assemble.dependsOn shadowJar reobf { re shadowJar {} } publishing { publications { mavenJava(MavenPublication) { artifact jar } } repositories { maven { url "file://${project.projectDir}/mcmodsrepo" } } } my entire project:https://github.com/kevin051606/DERP-Mod/tree/Derp-1.0-1.20
  • Topics

  • Who's Online (See full list)

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.